<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="企业名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qymc">
              <a-input v-model="model.qymc" placeholder="请输入企业名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="代征号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="dzh">
              <a-input v-model="model.dzh" placeholder="请输入代征号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="办税服务厅" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fwt">
              <a-input v-model="model.fwt" placeholder="请输入办税服务厅"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="被代征纳税人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bdznsr">
              <a-input v-model="model.bdznsr" placeholder="请输入被代征纳税人"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="被代征纳税人识别号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bdznsrsbh">
              <a-input v-model="model.bdznsrsbh" placeholder="请输入被代征纳税人识别号"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="征收项目" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zsxm">
              <a-input v-model="model.zsxm" placeholder="请输入征收项目"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="征收品目" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="zspm">
              <a-input v-model="model.zspm" placeholder="请输入征收品目"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="税款所属期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="skssq">
              <a-input v-model="model.skssq" placeholder="请输入税款所属期"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="交易金额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="jsyj">
              <a-input v-model="model.jsyj" placeholder="请输入交易金额"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="税率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sl">
              <a-input v-model="model.sl" placeholder="请输入税率"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="应代征税额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ydzse">
              <a-input v-model="model.ydzse" placeholder="请输入应代征税额"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="实缴税额" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sjse">
              <a-input v-model="model.sjse" placeholder="请输入实缴税额"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="录入日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="lrrq">
              <j-date placeholder="请选择录入日期" v-model="model.lrrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="税款日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="skrq">
              <j-date placeholder="请选择税款日期" v-model="model.skrq"  style="width: 100%" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'

  export default {
    name: 'BuGsfwptRlzyForm',
    components: {
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data () {
      return {
        model:{
         },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/rlzy/buGsfwptRlzy/add",
          edit: "/rlzy/buGsfwptRlzy/edit",
          queryById: "/rlzy/buGsfwptRlzy/queryById"
        }
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }

        })
      },
    }
  }
</script>